<?php

// deprecated: use spButtons and spButton

class spFormButtons extends spDiv
{
	private $buttons;

	public function __construct( $buttons )
	{
		parent::__construct();
		$this->buttons = $buttons;
		$this->processButtons();
	}
	
	private function processButtons()
	{
		foreach ( $this->buttons as $but )
		{
			$name 	= isset($but["name"]) ? $but["name"] : "";
			$class 	= isset($but["class"]) ? $but["class"] : "";
			$type 	= isset($but["type"]) ? $but["type"] : "";
			$value	= isset($but["value"]) ? $but["value"] : "";
		
			switch ( $type )
			{
				case "submit":
					{
						$b = new spInput(array(
							"class"	=> "spAjaxForm",
							"type" 	=> "submit",
							"name" 	=> $name,
							"value"	=> $value
						));
					}
					break;
			
				case "redirect":
					{
						$b = new spInput(array(
							"class"	=> "spRedirect",
							"type" 	=> "submit",
							"name" 	=> $name,		// redirect
							"value"	=> $value		// displayed text
						));
					
						/*
						$b = new spAnchor(array(
							"class" 	=> "button",
							"href"		=> "admin.php?page=".$name,
							"content" 	=> $value
						));
						*/
					}
					break;
		
				default:
					{
						$b = new spInput(array(
							"class" => $class,
							"type" 	=> "button",
							"name" 	=> $name,
							"value" => $value
						));
					}
			}
			
			if ( isset($but["disabled"]) )
				$b->addAttr( "disabled", "disabled" );
				
			if ( isset($but["id"]) )
				$b->addAttr( "id", $but["id"] );			
			
			$this->addChild( $b );
		}	
	}
}

?>